{% set pypi_name = 'osc-lib' %}
{% set upstream_version = upstream_version('2.3.0') %}
{% set rpm_release = '1' %}
{% set source = url_pypi() %}

Name:           {{ py2name() }}
Version:        {{ py2rpmversion() }}
Release:        {{ py2rpmrelease() }}
Summary:        OpenStackClient Library
License:        {{ license('Apache-2.0') }}
Group:          Development/Languages/Python
URL:            https://docs.openstack.org/developer/osc-lib
Source0:        {{ source }}
BuildRequires:  openstack-macros
BuildRequires:  {{ py3('Babel') }}
BuildRequires:  {{ py3('cliff') }}
BuildRequires:  {{ py3('fixtures') }}
BuildRequires:  {{ py3('keystoneauth1') }}
BuildRequires:  {{ py3('mock') }}
BuildRequires:  {{ py3('openstacksdk') }}
BuildRequires:  {{ py3('oslo.i18n') }}
BuildRequires:  {{ py3('oslo.utils') }}
BuildRequires:  {{ py3('oslotest') }}
BuildRequires:  {{ py3('osprofiler') }}
BuildRequires:  {{ py3('pbr') }}
BuildRequires:  {{ py3('requests-mock') }}
BuildRequires:  {{ py3('simplejson') }}
BuildRequires:  {{ py3('six') }}
BuildRequires:  {{ py3('stestr') }}
BuildRequires:  {{ py3('stevedore') }}
BuildRequires:  {{ py3('testtools') }}
BuildArch:      noarch

%description
OpenStackClient (aka OSC) is a command-line client for OpenStack.  osc-lib
is a package of common support modules for writing OSC plugins.

%package -n {{ py2name(py_versions='py3') }}
Summary:        OpenStackClient Library
Requires:       {{ py3('Babel') }}
Requires:       {{ py3('cliff') }}
Requires:       {{ py3('keystoneauth1') }}
Requires:       {{ py3('openstacksdk') }}
Requires:       {{ py3('oslo.i18n') }}
Requires:       {{ py3('oslo.utils') }}
Requires:       {{ py3('pbr') }}
Requires:       {{ py3('simplejson') }}
Requires:       {{ py3('six') }}
Requires:       {{ py3('stevedore') }}

%description -n {{ py2name(py_versions='py3') }}
OpenStackClient (aka OSC) is a command-line client for OpenStack.  osc-lib
is a package of common support modules for writing OSC plugins.

This package contains the Python 3.x module.

%package -n python-osc-lib-doc
Summary:        Documentation for the OpenStack client library
BuildRequires:  {{ py3('Sphinx') }}
BuildRequires:  {{ py3('openstackdocstheme')}}
BuildRequires:  {{ py3('reno') }}
BuildRequires:  {{ py3('sphinxcontrib-apidoc') }}

%description -n python-osc-lib-doc
Documentation for the OpenStack client library.

%prep
%autosetup -p1 -n {{ pypi_name }}-{{ upstream_version }}
%py_req_cleanup

%build
%{py3_build}

%install
%{py3_install}

# generate html docs
PBR_VERSION=%{version} PYTHONPATH=. %sphinx_build -a -E -d doc/build/doctrees -b html doc/source doc/build/html
# remove the sphinx-build leftovers
rm -rf doc/build/html/.{doctrees,buildinfo}

%check
python3 -m stestr.cli run

%files -n {{ py2name(py_versions='py3') }}
%license LICENSE
%doc README.rst ChangeLog
%{python3_sitelib}/osc_lib
%{python3_sitelib}/*.egg-info

%files -n python-osc-lib-doc
%license LICENSE
%doc doc/build/html

%changelog
